package ioDemo;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class ByteDemo {

	public static void main(String[] args) {
		try (InputStreamReader sin = new InputStreamReader(System.in);
				BufferedReader bin = new BufferedReader(sin);
				FileOutputStream out = new FileOutputStream("F:\\JavaProject\\ioDemo\\src\\ioDemo\\myfile.txt");
				OutputStreamWriter osw = new OutputStreamWriter(out, "gbk");
				BufferedWriter bout = new BufferedWriter(osw);) {
			String line;
			while (true) {
				line = bin.readLine();
				if (line.length() > 0) {
					bout.write(line);
					bout.newLine();
				}else {
					break;
				}				
			}
			bout.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
